package com.galeno.redis;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

import java.util.List;

/**
 * @author galeno
 * @Title:
 * @Description:
 * @date 2021/9/149:47
 */
public class RedisListAPI {

    public static void main(String[] args) {
        /**
         * 获取一个连接池哦
         */
        JedisPool jedisPool = new JedisPool("galeno01", 6379);
        /**
         * 连接池中获取一个连接
         */
        Jedis jedis = jedisPool.getResource();
        //从左面追加
        Long lpush = jedis.lpush("number", "1","2","3");
        Long number2 = jedis.rpush("number", "4", "5", "6");
        System.out.println(lpush);

        List<String> numbner = jedis.lrange("number", 0, 5);
        System.out.println(numbner);

        //从list中弹出元素

        String number = jedis.lpop("number");
        System.out.println(number);
        String number1 = jedis.rpop("number");
        System.out.println(number1);
        jedis.close();
        jedisPool.close();


    }
}
